package com.ethan.protostuff;

/**
 * @author ethan
 * create 2018-06-12 下午7:52
 * desc
 **/
public class TestProtostuff {
    public static void main(String[] args){
//
//        // new User instance
//        User user = new User("name", "passoword", 12L);
//
//        LinkedBuffer buffer = LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE);
//
//        Schema<User> schema = RuntimeSchema.createFrom(User.class);
//
//        // 序列化 user 类
//        byte[] bytes = ProtostuffIOUtil.toByteArray(user, schema, buffer);
//
//        User t = new User();
//
//        // 将 bytes 反序列化 ， 存储到 t 变量里面
//        ProtostuffIOUtil.mergeFrom(bytes, t, schema);
//
//        System.out.println("反序列化结果：" + t);


        User user = new User("name", "passoword", 12L);

        //SerializationUtil
////        byte[] bytes = SerializationUtil.serialize(user);
////        User user2 = SerializationUtil.deserialize(bytes,User.class);

        //SerializationUtil2
        byte[] bytes = SerializationUtil2.serialize(user);
        User user3= SerializationUtil2.deserialize(bytes,User.class);

        String a ="";
    }
}
